package com.jaws.core.configuration;

import java.util.List;

import lombok.Data;

import org.springframework.boot.context.properties.ConfigurationProperties;

import com.google.common.collect.Lists;

/**
 * 分表规则
 * eg:
 * #表名
 * shard.rules[0].table=test_shard_account_trade
 * #均衡字段
 * shard.rules[0].balanceColumn=user_id
 * #分表算法(sping bean id)
 * shard.rules[0].shardAlgorithm=baseShardAlgorithm
 * <p>
 * shard.rules[1].table=account_flow
 * shard.rules[1].balanceColumn=user_id
 * shard.rules[1].shardAlgorithm=baseShardAlgorithm
 *
 * @author liangqm
 * @date 2018-05-04 16:45:18
 * @since v1.0.2
 */
@ConfigurationProperties(prefix = "shard")
@Data
public class ShardTableProperties {

	private List<TableRule> rules = Lists.newArrayList();

	@Data
	public static class TableRule {
		/**
		 * 表名称
		 */
		private String table;

		/**
		 * 分片列
		 */
		private String balanceColumn;

		/**
		 * 分片算法,spring beanId
		 */
		private String shardAlgorithm;
	}
}
